<style>
#list td {
	border-bottom:#13B1E4 1px solid;
	border-right:#13B1E4 1px solid;}

</style>

<script type="text/javascript">

function doDelete(url)
{
	var a = confirm('Are you sure?');
	if(a)
	{
		window.location = url;
	}
}

function doUpdateStatus(obj, id){
	var a = confirm('Are you sure?');
	if(a)
	{
		status = obj.options[obj.selectedIndex].value;
		window.location = "?page=usersManager&sub=updateStatus&status="+status+"&userId="+id;
	} 
}

function doFilter(obj)
{
	var filterId = obj.options[obj.selectedIndex].value;
	window.location = "?page=areaManager&filterBy="+filterId;
	///alert(filterId);
}


</script>
<!-- CONTENT START -->
<div id="content">

<!-- LEFT START -->
<?php
include('themes/'.$this -> theme.'/left.php');
?>
<!-- LEFT END -->

<!-- RIGHT START -->
<div id="right">

<h2 class="right_heading">Area Manager</h2>
<div id="shop_anounce">

<?= $this -> renderStatus($cmd)?>

<form action="?page=areaManager&sub=<?=$action?>" method="post">
<input type="hidden" name="cityId" value="<?=$editArea['cityID']?>" />
<!--<input type="hidden" name="filterBy" value="<?=$editArea['regionID']?>" />-->

<table width="450">
<tr>
	<td>Region Name</td>
	<td align="left" valign="baseline">
    	<select name="regionId">
        <?php foreach($regions as $region): ?>
        	<option value="<?=$region['regionID']?>" <?php if($region['regionID']==$editArea['regionID']) print "selected='selected'" ?>>
			<?=$region['regionName']?></option>
        <?php endforeach; ?>
        </select>
    </td>
</tr>


<tr>
	<td>City Name</td>
	<td align="left" valign="baseline"><input type="text" name="cityName" id="cityName" value="<?=$editArea['cityName']?>" size="40" /></td>
</tr>

<tr>
	<td>&nbsp;</td>
	<td colspan="2" align="left" valign="baseline">
    <input  type="submit" value="<?=($action=="Save"?"Save":"Update")?> City" /></td>
</tr>
</table>

<br />
<?php if (!isset($this -> data['cityId'])){ ?>
Filter By: 
            <select name="filterBy" onchange="doFilter(this)">
            <option value="0" selected="selected">All</option>
            <?php foreach($regions as $region): ?>
                <option value="<?=$region['regionID']?>" <?php if($region['regionID']==$filterBy) print "selected='selected'" ?>><?=$region['regionName']?></option>
            <?php endforeach; ?>
            </select>
<?php } ?>
</form>

<?php if (!isset($this -> data['cityId'])){ ?>

<table width="650" border="0" id="list">
  <tr>
    <td bgcolor="#CCCCCC" width="150">City Name</td>
    <td bgcolor="#CCCCCC" width="60">Edit</td>
    <td bgcolor="#CCCCCC" width="30">Delete</td>
  </tr>
  <?php
  foreach($arrAreas as $area): 
	  $urlDelete = "?page=areaManager&sub=delArea&cityId=".$area['cityID'];
	  $urlEdit = "?page=areaManager&cityId=".$area['cityID'];
  ?>
  <tr>
    <td><?=$area['cityName']?></td>
    <td align="center"><a href="<?=$urlEdit?>"><img src="iconset/pencil_16.png" alt="Edit" border="0" /></a></td>
   <td align="center"><img src="iconset/delete_16.png" alt="Delete" onclick="doDelete('<?= $urlDelete?>')" /></td>
  </tr>
  <?php
  endforeach;
  ?>
</table>

<?php } ?>

</div>
</div>
<!-- RIGHT END -->

<!-- Just to increase height automatically --><div id="height_increaser"></div>

</div>
<!-- CONTENT END -->
<div id="content_end"></div>